#!/bin/sh
. $HOME/.config/defaultprograms.txt
case "$1" in
 -default)
 echo $IMAGEEDITOR > $HOME/.config/tmp/editor
 
 programchooser $IMAGEEDITOR gtk-preferences 2DGraphics Viewer > $HOME/.config/tmp/imageeditor
 cat $HOME/.config/defaultprograms.txt | grep -v IMAGEEDITOR > $HOME/.config/defaultprograms.new
 IMAGEEDITOR="`cat $HOME/.config/tmp/imageeditor`"
 [ "$IMAGEEDITOR" = "" ] && IMAGEEDITOR="cat $HOME/.config/tmp/editor"
 echo IMAGEEDITOR=\"$IMAGEEDITOR\" >> $HOME/.config/defaultprograms.new
 mv -f $HOME/.config/defaultprograms.new $HOME/.config/defaultprograms.txt
 rm -f $HOME/.config/tmp/editor
 rm -f $HOME/.config/tmp/imageeditor
 ;;
 *)
 exec $IMAGEEDITOR "$@"
 ;;
esac
